package Interface.User;

import Controller.Client;
import Mapper.Admin.zhujiemian;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.stage.Stage;

import java.io.FileInputStream;
import java.sql.*;

import static pojo.Mysql.*;

public class huiYuan extends Application {
    Label d3 ,d4 ,re ,d1 ;
    @Override
    public void start(Stage stage) throws Exception {
        FileInputStream input=new FileInputStream("C:\\Users\\86178\\Videos\\R-C (1).jpg");
        Image image = new Image(input);
        ImageView imageView =new ImageView(image);
        imageView.setFitWidth(488);
        imageView.setFitHeight(465);

        Connection connection = null;
        try {
            connection = DriverManager.getConnection(url, user, dbPassword);
        } catch (Exception throwables) {
            System.out.println("连接失败");
        }

        System.out.println(Client.id);
        try {
            Statement statement = connection.createStatement();
            String query = "SELECT * FROM huiyuan WHERE username = '"+Client.id+"'" ;
            ResultSet resultSet = statement.executeQuery(query);

            // 输出查询结果
            while (resultSet.next()) {
                String retrievedName = resultSet.getString("name");
                String data1 = resultSet.getString("id");
                String data2 = resultSet.getString("bankaqingkuang");
                String data3 = resultSet.getString("createtime");

                d3 =new Label("姓名："+retrievedName);
                d4 =new Label("id："+data1);
                re =new Label("开卡时间："+data3);
                d1 =new Label("会员等级："+data2);
                System.out.println("Name: " + retrievedName);
                System.out.println("Data1: " + data1);
                System.out.println("Data2: " + data2);
                System.out.println("Data3: " + data3);
            }
            boolean success = resultSet.next();
            resultSet.close();
            statement.close();
        } catch (SQLException e) {
            System.out.println("头像信息失败");
        }

//        HBox hBox =new HBox(imageView);
        Pane pane = new Pane();
        pane.getChildren().add(imageView);
        pane.getChildren().addAll(d3,d4,d1,re);

        d3.setLayoutX(10);
        d3.setLayoutY(0);
        d3.setFont(Font.font(20));
        d3.setTextFill(Color.RED);

        d4.setLayoutX(10);
        d4.setLayoutY(50);
        d4.setFont(Font.font(20));
        d4.setTextFill(Color.RED);

        re.setLayoutX(10);
        re.setLayoutY(100);
        re.setFont(Font.font(20));
        re.setTextFill(Color.RED);

        d1.setLayoutX(10);
        d1.setLayoutY(150);
        d1.setFont(Font.font(20));
        d1.setTextFill(Color.RED);



        Scene scene =new Scene(pane);
        stage.setScene(scene);
        stage.setTitle("个人信息");
        stage.setWidth(500);
        stage.setHeight(500);
        stage.setResizable(false);//窗口不可拉伸
        stage.show();
    }

}
